package my.test.iterator.best;

import java.util.ArrayList;

/**
 * @Author 许玉康
 * @Date 2019/9/5 12:54
 */
public class Project implements IProject {

    //定义一个项目列表，所有的项目都放在这里
    private ArrayList<IProject> projectArrayList = new ArrayList<>();
    private String name = "";
    private int num = 0;
    private int cost = 0;

    public Project() {
    }

    public Project(String name, int num, int cost) {
        this.name = name;
        this.num = num;
        this.cost = cost;
    }

    //增加项目
    @Override
    public void add(String name, int num, int cost) {
        this.projectArrayList.add(new Project(name, num, cost));
    }

    //得到项目信息
    @Override
    public String getProjectInfo() {
        return this.name + this.num + this.cost;
    }

    @Override
    public IProjectIterator iterator() {
        return new ProjectIterator(this.projectArrayList);
    }
}
